basepath=$(realpath $(dirname $0))
cd $basepath
source ${basepath}/settings.sh

mkdir /mnt/d1 /mnt/d2 /mnt/d3 /mnt/d4 /mnt/d5
mkdir /data /bak_1 /bak_2 /lopt
if [ ! -f /etc/fstab_origin ]; then
    cp /etc/fstab /etc/fstab_origin
else
    cp /etc/fstab_origin /etc/fstab
fi
lastest_fstab_path=/etc/fstab_init_bash_backup_`date +%Y%m%d_%H%m%S`
echo "The lastest_fstab_path is: ${lastest_fstab_path}"
cp /etc/fstab $lastest_fstab_path
echo "backuped the /etc/fstab as ${lastest_fstab_path}"
echo -n "#" >> /etc/fstab
sed -i /centos-home/s/^/#/ /etc/fstab
msg="I recommended the origin /home mount rule, in order to add my own, for mount /home as a particial on 500g machine disk, for the long age across the system resetup on ssd disk."
echo $msg >> /etc/fstab
echo $msg
cat >> /etc/fstab << EOF
/dev/sda1 /data                   xfs     defaults        0 0
/dev/sda2 /home                   xfs     defaults        0 0
/dev/sda3 /bak_1                   xfs     defaults        0 0
/dev/sda4 /bak_2                   xfs     defaults        0 0
/dev/sda5 /lopt                  xfs     defaults        0 0
EOF

mount -a
cp /bak_1/hhome / -rf
chmod 777 /hhome
echo "copped /bak_1/hhome to / -rf"
chown lk:lk /hhome/hlk -R
echo "chowned lk:lk /hhome/hlk -R"
ln -s /hhome/hlk/.emacs.d /home/lk/ -f
echo "lned -s /home/hhome/hlk/.emacs.d /home/lk/ -f"
ls -al /home/lk | grep .emacs.d
chown lk:lk /home/lk -R
echo "chown lk:lk /home/lk -R"


echo the new /etc/fstab is:
cat /etc/fstab

fstab_ensure_question_str="If you feel the content of /etc/fstab is incorrect, press the CTRL-C to interrupt the bash, and modify the disk.sh to right.\nIf not do this, you must modify the /etc/fstab to right, or you may cannot loggin account follow your mind when next reboot this machine.\nIf you feel the conent of /etc/fstab is correct, input string 'correct', and press ENTER, to continue.\npress 'CTRL-C' or input 'correct' and press 'ENTER'?\n"
ensure_key=''
while [[ ! $ensure_key == 'correct' ]]; do
    echo -e $fstab_ensure_question_str
    read -p "Got your ensure_key: " ensure_key
done
echo "Now the ensure_key is ${ensure_key}, run below flow..."
